home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 16 June 1997
- // Author: cdt
- //
- // Procedure Name:
- // getCameraNode
- //
- // Description:
- // Procedure to get the name of a camera node.
- //
- // Input Arguments:
- // node - name of node to get
- // camera - camera name to get nodes for
- //
- // Return Value:
- // Name of the requested camera node
- //
-
- //
- // Procedure Name:
- // getLookAtNode
- //
- proc string getLookAtNode( string $camera )
- {
- string $lookAts[] = `listConnections ($camera+".rotateX")`;
-
- if (size($lookAts) == 0 || `objectType $lookAts[0]` != "lookAt")
- $lookAts = `listConnections ($camera+".rotateY")`;
-
- if (size($lookAts) == 0 || `objectType $lookAts[0]` != "lookAt")
- $lookAts = `listConnections ($camera+".rotateZ")`;
-
- return (size($lookAts) == 0 || `objectType $lookAts[0]` != "lookAt") ?
- "" : $lookAts[0];
- }
-
- //
- // Procedure Name:
- // getViewNode
- //
- proc string getViewNode( string $camera )
- {
- string $views[];
-
- string $lookAt = getLookAtNode( $camera );
-
- if ($lookAt != "") {
- $views = `listConnections ($lookAt+".target[0].targetTranslateX")`;
-
- if (size($views) == 0 || `objectType $views[0]` != "transform")
- $views = `listConnections ($lookAt+".target[0].targetTranslateY")`;
-
- if (size($views) == 0 || `objectType $views[0]` != "transform")
- $views = `listConnections ($lookAt+".target[0].targetTranslateZ")`;
- }
-
- return (size($views) != 0 && `objectType $views[0]` == "transform") ?
- $views[0] : "";
- }
-
- //
- // Procedure Name:
- // getUpNode
- //
- proc string getUpNode( string $camera )
- {
- string $ups[];
-
- string $lookAt = getLookAtNode( $camera );
-
- if ($lookAt != "")
- $ups = `listConnections ($lookAt+".worldUpMatrix")`;
-
- return (size($ups) > 0) ? $ups[0] : "";
- }
-
- //
- // Procedure Name:
- // cameraNode
- //
- global proc string getCameraNode( string $node, string $camera )
- {
- string $result = "";
-
- if ( "camera" == `nodeType $camera` ) {
- // In cases where there are more than one shape under a transform and
- // one of them is a camera, it is possible that this method will be
- // called with the actual camera node instead of the transform above
- // it. Compensate.
- //
- string $parents[] = `listRelatives -parent $camera`;
- $camera = $parents[0];
- }
-
- switch ($node) {
- case "lookAt":
- $result = getLookAtNode( $camera );
- break;
-
- case "view":
- $result = getViewNode( $camera );
- break;
-
- case "up":
- $result = getUpNode( $camera );
- break;
- }
-
- return $result;
- }
-